package com.leonzhangxf.server;

import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author leonzhangxf
 */
@Service
@org.springframework.stereotype.Service
public class ProviderServiceImpl implements ProviderService {

    @Override
    public String methodA(String msg) {
        sleep100RandomMillis(300);
        return String.format("A %s", msg);
    }

    @Override
    public String methodB(String msg) {
        sleep100RandomMillis(100);
        return String.format("B %s", msg);
    }

    @Override
    public String methodC(String msg) {
        sleep100RandomMillis(100);
        return String.format("C %s", msg);
    }

    private void sleep100RandomMillis(long bound) {
        try {
            Thread.sleep(ThreadLocalRandom.current().nextLong(bound));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
